﻿using System;
using System.Collections.Generic;
using Microsoft.SharePoint;

namespace ServBus.ListForm2013.Utility
{
    public class InfoPathContext
    {
        private string mXsdSchemaValue;
        private List<string> mFilesNeedToBeCleared;
        private string mTime;
        private string mPath;
        private List<string> mFilesBeSaved;
        private List<string> mListNames;
        private List<string> mAddedSecondaryListNames;
        private Dictionary<string, string> mSelectedContent;
        private string mXsnFilePath;
        private string mXsnName;

        private string mTemporaryXsnName = "TemporaryXsn";
        public string TemporaryXsnName
        {
            get { return mTemporaryXsnName; }
            set { mTemporaryXsnName = value; }
        }
        //2011-11-17
        private SPWeb web;
        public SPWeb Web
        {
            get
            {
                return web;
            }
            set
            {
                web = value;
            }
        }
        private string mCurSiteUrl;
        public string CurrentSiteUrl
        {
            get
            {
                return mCurSiteUrl;
            }
            set
            {
                mCurSiteUrl = value;
            }
        }
        private string mListName;
        public string ListName
        {
            get
            {
                return mListName;
            }
            set
            {
                mListName = value;
            }
        }

        private string mListID;
        public string ListID
        {
            get
            {
                return mListID;
            }
            set
            {
                mListID = value;
            }
        }

        public string XsnName
        {
            get
            {
                return mXsnName;
            }
            set
            {
                mXsnName = value;
            }
        }

        public Dictionary<string, string> SelectedContent
        {
            get
            {
                if (mSelectedContent == null)
                {
                    mSelectedContent = new Dictionary<string, string>();
                }
                return mSelectedContent;
            }
        }

        public string XsnPath
        {
            get
            {
                return mXsdSchemaValue;
            }
            set
            {
                mXsdSchemaValue = value;
            }
        }

        public List<string> AddedSecondaryListNames
        {
            get
            {
                if (mAddedSecondaryListNames == null)
                {
                    mAddedSecondaryListNames = new List<string>();
                }
                return mAddedSecondaryListNames;
            }
            set
            {

                mAddedSecondaryListNames = value;
            }
        }

        public List<string> FilesBeSaved
        {
            get
            {
                if (mFilesBeSaved == null)
                {
                    mFilesBeSaved = new List<string>();
                }
                return mFilesBeSaved;
            }
            set
            {
                mFilesBeSaved = value;
            }
        }

        public List<string> ListNames
        {
            get
            {
                if (mListNames == null)
                {
                    mListNames = new List<string>();
                }
                return mListNames;
            }
            private set
            {
                mListNames = value;
            }
        }

        public void AddListNames(string listNam)
        {
            if (!ListNames.Contains(listNam))
            {
                ListNames.Add(listNam);
            }
        }

        public void AddSavedFile(string filePath)
        {
            if (!FilesBeSaved.Contains(filePath))
            {
                FilesBeSaved.Add(filePath);
            }
        }

        public string XSDSchemaValue
        {
            get
            {
                if (mXsdSchemaValue == null)
                {
                    //string prefix = "http://schemas.microsoft.com/office/infopath/2003/myXSD/";// + 2011-06-24T15:57:44
                    mXsdSchemaValue = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-06-30T11:22:21";
                }

                return mXsdSchemaValue;
            }
            set
            {
                mXsdSchemaValue = value;
            }
        }

        public string Path
        {
            get
            {
                if (mPath == null)
                {
                    mPath = NameSpaceConstants.Des_Root_Path + Guid.NewGuid() + "\\";
                }
                return mPath;
            }
        }

        public string Time
        {
            get
            {
                if (mTime == null)
                {
                    mTime = "2011-06-24T15:57:44";
                }
                return mTime;
            }
        }

        public List<string> FilesToBeCleared
        {
            get
            {
                if (mFilesNeedToBeCleared == null)
                {
                    mFilesNeedToBeCleared = new List<string>();
                }
                return mFilesNeedToBeCleared;
            }
            set
            {
                mFilesNeedToBeCleared = value;
            }
        }

        private Uri mPageUrl;
        public Uri PageUrl
        {
            get
            {
                return mPageUrl;
            }
            set
            {
                mPageUrl = value;
            }
        }

        //add for config
        private string mListContentTypeID;
        public string ListContentTypeID
        {
            get
            {
                return mListContentTypeID;
            }
            set
            {
                mListContentTypeID = value;
            }
        }

        private string mListContentTypeName;
        public string ListContentTypeName
        {
            get
            {
                return mListContentTypeName;
            }
            set
            {
                mListContentTypeName = value;
            }
        }

        private string mXsnLocation;
        public string XsnLocation
        {
            get
            {
                return mXsnLocation;
            }
            set
            {
                mXsnLocation = value;
            }
        }

        private string mMainListFullUrl;
        public string MainListFullUrl
        {
            get
            {
                return mMainListFullUrl;
            }
            set
            {
                mMainListFullUrl = value;
            }
        }

        //add for default view
        private List<FieldInfo> mMainListFields;
        public List<FieldInfo> MainListFields
        {
            get
            {
                return mMainListFields;
            }
            set { mMainListFields = value; }
        }

        //add for default view
        private List<ListInfo> secondListInfos;
        public List<ListInfo> SecondListInfos
        {
            get
            {
                return secondListInfos;
            }
            set { secondListInfos = value; }
        }
    }
}
